package com.junglone.gateway.admin.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * Description: 路由实例, 继承 {@link org.springframework.cloud.gateway.route.RouteDefinition}
 *
 * @author junglone: <a href="mailto:cjlnzb@hotmail.com">cjlnzb@hotmail.com</a>
 * @since 2021/04/02 12:21
 */
@Document("route")
public class MongoRoute extends RouteDefinition {

	/**
	 * 路由 id ---- 唯一索引, 会导致无法使用 save() 方法更新数据
	 */
	@NotNull
	@Indexed(name = "unique_route_id", unique = true, background = true)
	private String routeId;
	
	/**
	 * 当前使用状态
	 */
	private int currentStatus = 1;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date updateTime;

	public String getRouteId() {
		return routeId;
	}

	public void setRouteId(String routeId) {
		this.routeId = routeId;
	}

	public int getCurrentStatus() {
		return currentStatus;
	}

	public void setCurrentStatus(int currentStatus) {
		this.currentStatus = currentStatus;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
}
